function addClick()
{
    dnn.controls.controls['ctl00_NavMenu'].add_handler('click', onclickHandler);
    if (dnn.controls.controls['ctl00_ContentPlaceHolder1_MyDNNMenu'])
    {
        dnn.controls.controls['ctl00_ContentPlaceHolder1_MyDNNMenu'].add_handler('callBackFail', onCallbackFail);
        dnn.controls.controls['ctl00_ContentPlaceHolder1_MyDNNMenu'].add_handler('callBackSuccess', onCallbackSuccess);
    }
}

function onCallbackFail(src, arg)
{
    alert('FAIL!');
    alert(arg.get_result());
}

function onCallbackSuccess(src, arg)
{
    alert('SUCCESS!');
    alert(arg.get_result());
}

function onclickHandler(src, args)
{
    var mNode = args.get_node();
    //args.set_cancel(true);
    alert('click' + mNode.id);
}

var m_oStatus;
function myTestFunction(param1, param2)
{			
	alert('The following js function was called: myTestFunction \n params: (' + param1 + ', ' + param2 + ')');
	return confirm('Do wish to continue?');
}

function myJSExtFunction(sKey)
{
	alert('You clicked on a file with a .js extension: ' + sKey); 
	return confirm('Do wish to continue?');
}

function myJSNavFunction(sKey)
{
	return confirm('This will navigate the IFRAME to the following page: ' + sKey + '\nDo you wish to Continue?');
}

function __dnn_ClientAPIEnabled()
{
	return typeof(dnn) != 'undefined';
}

function writeStatus(s)
{
	if (m_oStatus == null)
		m_oStatus = $(m_sNS + '_txtStatus');
	
	m_oStatus.value = s + ' (' + new Date().getMinutes() + ':' + new Date().getSeconds() + ')\n' + m_oStatus.value;
}
function callbackStatus(result, ctx)
{
	if (isNaN(result))
		writeStatus('Callback Status: Complete - Payload Size=' + result.length);
	else 	
		writeStatus('Callback Status: ' + result);
}

function init()
{
	if (__dnn_ClientAPIEnabled())
	{
		if (dnn.xml != null)
			writeStatus('XML Parser: ' + dnn.xml.parserName);
		else
			writeStatus('XML Parser: N/A');
		
		if (dnn.xmlhttp != null)
			writeStatus('XMLHTTP Transport: ' + dnn.xmlhttp.parserName);
		else
			writeStatus('XMLHTTP Parser: N/A');
	}
	else
		writeStatus('DownLevel Rendering');
		
}

function promptForSave(evt, ctl)
{
	return confirm('Are you sure you wish to save this text?\n' + ctl.editWrapper.getText());
	//return true;
}
